package com.huike.web.controller.report;


import com.huike.common.core.domain.AjaxResult;
import com.huike.report.service.IReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/index")
public class IndexController {

    @Autowired
    private IReportService reportService;


    /**
     * 首页--基础数据统计
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getBaseInfo")
    public AjaxResult getBaseInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getBaseInfo(beginCreateTime,endCreateTime));
    }

    /**
     * 获取首页基础数据信息（今日简报部分数据，即在首页展示当前用户在当天的线索数量，商机数量，合同数量，成交的金额）
     * @return
     */
    @GetMapping("/getTodayInfo")
    public AjaxResult getTodayInfo(){
        return AjaxResult.success(reportService.getTodayInfo(new SimpleDateFormat("yyyy-MM-dd").format(new Date())));
    }

    /**
     * 首页-查询当前用户待跟进的线索，商机，和待分配的线索和商机
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/getTodoInfo")
    public AjaxResult getTodoInfo(@RequestParam("beginCreateTime") String beginCreateTime,
                                  @RequestParam("endCreateTime") String endCreateTime){
        return AjaxResult.success(reportService.getTodoInfo(beginCreateTime,endCreateTime));
    }

    /**
     * 首页--商机转化龙虎榜接口
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/businessChangeStatistics")
    public AjaxResult getBusinessChangeStatistics(@RequestParam("beginCreateTime") String beginCreateTime,
                                                  @RequestParam("endCreateTime") String endCreateTime){
        List<Map<String, Object>> list = reportService.getBusinessChangeStatistics(beginCreateTime, endCreateTime);
        return AjaxResult.success(list);
    }

    /**
     * 首页-线索转化龙虎榜接口
     * @param beginCreateTime
     * @param endCreateTime
     * @return
     */
    @GetMapping("/salesStatistic")
    public AjaxResult getSalesStatistics(@RequestParam("beginCreateTime") String beginCreateTime,
                                         @RequestParam("endCreateTime") String endCreateTime){
        List<Map<String, Object>> list = reportService.getSalesStatistics(beginCreateTime, endCreateTime);
        return AjaxResult.success(list);
    }

}